package com.vanysoft.business.sys.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.vanysoft.business.sys.entity.Dictionary;
import com.vanysoft.business.sys.service.DictionaryService;
import com.vanysoft.framework.base.action.BaseController;
import com.vanysoft.framework.utils.JSONResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 字典表 前端控制器
 * </p>
 *
 * @author YangLei
 * @since 2018-07-08
 */
@Controller
@RequestMapping("/sys/dictionary")
public class DictionaryController extends BaseController {

    @Autowired
    DictionaryService dictionaryService;

    @RequestMapping("query")
    @ResponseBody
    public JSONResponse queryByCode(String code) {
        List<Dictionary> list = dictionaryService.selectList(new EntityWrapper<Dictionary>().eq("code", code));
        return new JSONResponse(list);
    }

    @RequestMapping("list")
    @ResponseBody
    public JSONResponse list(String[] code) {
        Wrapper<Dictionary> wrapper = null;
        if (code != null && code.length != 0) {
            wrapper = new EntityWrapper<Dictionary>().in("code", code);
        }
        List<Dictionary> list = dictionaryService.selectList(wrapper);
        return new JSONResponse(list);
    }
}

